<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>sse</title>

<script type="text/javascript" src = "/spring-maven-demo/assets/js/jquery-1.11.0.min.js"></script>

</head>
<body>
<hr>
<hr>
<hr>
<hr>
	<div id = "msgFrompPush">
		
	</div>
	
	<script type="text/javascript">
	
		if(!!window.EventSource){
			var source = new EventSource('/spring-maven-demo/sse/push');
			
			s = '';
			
			source.addEventListener('message',function(e){
				console.log(e);
				s+= e.data+"<br/>";
				$("#msgFrompPush").html(s);
			});
			
			source.addEventListener('open', function(e){
				console.log("链接打开");
			});
			
			source.addEventListener('error', function(e){
				if(e.readyState == EventSource.CLOSED){
					console.log("链接关闭");
				} else {
					console.log(e.readyState);
				}
			}, false);
			
		} else {
			console.log("你的浏览器不支持SSE");
		}	
	
	</script>
</body>
</html>